package com.spark.market.controller;

import com.spark.market.api.dto.OrderInfo;
import com.spark.market.api.request.OrderCreateParam;
import com.spark.market.api.utils.ResponseResult;
import com.spark.market.api.utils.ResponseUtil;
import com.spark.market.common.utils.AssertUtils;
import com.spark.market.service.OrderCmdCoreService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("order/cmd")
public class OrderCmdController extends BaseController{
    @Resource
    private OrderCmdCoreService orderCmdCoreService;
    //创建订单
    @PostMapping(value = "create")
    public ResponseResult<OrderInfo> createOrder(@RequestBody OrderCreateParam param){
        AssertUtils.isNotNull(param, "OrderCreateParam is null");
        return ResponseUtil.createSuccessResult(orderCmdCoreService.createOrder(param),"success");
    }
}
